package com.zsgeek.wisdchain.qutu.view.find.adapter;

import android.content.SharedPreferences;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.google.gson.Gson;
import com.zsgeek.wisdchain.qutu.R;
import com.zsgeek.wisdchain.qutu.base.event.PreferenceHelper;

public class RecentSearchProductAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    Boolean isCourseWare;

    public RecentSearchProductAdapter() {
        super(R.layout.recent_search_product_item, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.setText(R.id.tv_recent_product_text, item);
        ImageView imageView = helper.getView(R.id.iv_clear);
        imageView.setOnClickListener(v -> {
            remove(helper.getPosition());
            SharedPreferences.Editor editor = PreferenceHelper.getInstance().getEditor();
            editor.putString("productSearchData", new Gson().toJson(getData()));
            editor.commit();
        });
    }
}
